#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef unsigned long long ULL;
const int N = 1e6 + 10, P = 131;
ULL hl[N],hr[N],p[N];
char str[N];

ULL get(ULL h[], int l, int r)
{
	return h[r] - h[l - 1] * p[r - l + 1];
}
int main()
{
	int t = 1;
	while (scanf_s("%s", str + 1), strcmp(str + 1, "END")) {
		int n = strlen(str + 1);
		for (int i = n * 2; i; i -= 2) {
			str[i] = str[i / 2];
			str[i - 1] = 'z' + 1;
		}
		n *= 2;
		p[0] = 1;
		for (int i = 1 ,j = n; i < n + 1; i++ , j--) {
			hl[i] = hl[i - 1] * P + str[i] - 'a' + 1;
			hr[i] = hr[i - 1] * P + str[j] - 'a' + 1;
			p[i] = p[i - 1] * P;
		}
		int res = 0;
		for (int i = 1; i <= n; i++) {
			int l = 0;
			int r = min(i - 1, n - i);
			while (l < r) {	
				int mid = l + r + 1 >> 1;
				if (get(hl,i-mid,i-1) != get(hr,n-(i+mid)+1,n-(i+1)+1)) {
					r = mid - 1;
				}
				else {
					l = mid;
				}
			}
			if (str[i-l] <= 'z') {
				res = max(res, r + 1);
			}
			else {
				res = max(res, r);
			}
		}
		cout << "Case "<< t++ << ": " << res << endl;
	}
	return 0;
}